<template>
    <div class="list">
        <div class="title">公司列表</div>
        <Table :columns="columns" :data="data" @on-row-click="go_detail($event)"></Table>
        <div class="page"><Page :total="pageInfo" :page-size="5" @on-change="get_list" show-total /></div>
    </div>
</template>
<style>
    .list{width:100%;font-size:16px;text-align:left;}
    .title{margin-bottom:15px;}
    .page{text-align:right;margin:10px;}
</style>
<script>
    export default {
        data () {
            return {
                pageInfo: 1,
                columns: [
                    {
                        title: '公司名称',
                        key: 'company_name'
                    },
                    {
                        title: '跟进人',
                        key: 'name'
                    },
                    {
                        title: '公司电话',
                        key: 'tel'
                    },
                    {
                        title: '公司邮编',
                        key: 'zip_code'
                    },
                    {
                        title: '公司地址',
                        key: 'address'
                    }
                ],
                data: []
            }
        },
        methods: {
            get_list: function(page) {
                let that = this
                this.$http.get('http://jorren-api.iccchina.com/company/customer/get_customer_list',{params:{page: page}})
                .then(function(data) {
                    that.data = data.data.list
                    that.pageInfo = data.data.cnt
                }, function(error) {
                    console.log(error)
                })
            },
            go_detail: function(e) {
                this.$router.push({path:'/company_detail',query: {cid:e.id}})
            }
        },
        created() {
            this.get_list(1)
        }
    }
</script>

